
var ns, toast;
var app = new Vue({
    el: '#app',
    data: {
        version:'',
    },
    methods: {
        //获取版本
        get_Banben:function(){
            var that=this;
            var opt = {
                action: 'getversion',
            };
            ns.post(opt, function(succeed, data, err) {
                if(succeed){
                    that.version=data.version;
                }else{
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                      });
                }
            });
        },
        //修改密码
        edit_promiss:function(){
            var that=this;
            ns.openWin('dl_editpassword', '修改密码');
        },
        //退出系统
        logout:function(){
            var that=this;
            that.$dialog.confirm({
                title: '提示信息',
                message: '确定要退出系统吗？',
                confirmButtonText:'确认',
                cancelButtonText:'取消',
            }).then(() => {
                var option={};
                option.action='loginout';
                ns.post(option, function(succeed, data, err) {
                    if(succeed){
                            api.toast({
                                msg: '已退出',
                                duration: 2000,
                                location: 'bottom'
                            });
                            api.removePrefs({
                                key: 'uid'
                            });
                            api.removePrefs({
                                key: 'busid'
                            });
                            api.removePrefs({
                                key: 'familyuid'
                            });
      
                            api.removePrefs({
                                key: 'isfirstchangepwd'
                            });
                            //操作成功后跳转到登录界面
                            setTimeout(function() {
                                ns.openWin('login_frm', '', {
                                    id: '',
                                });
                            }, 200);
                       
                    }else{
                        api.toast({
                            msg: err,
                            duration: 2000,
                            location: 'bottom'
                        });
                    }
    
                });
            }).catch(() => {
                // on cancel
              });
        }

    },
});

apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.get_Banben();
}
